<!-- 新增送修-科室-送修信息 -->
<template>
	<Card>
		<template #head>
			送修信息
		</template>
		<template #body>
			<CellField label="送修人" v-model="formData.sendUser" required></CellField>
			<CellField label="送修人电话" v-model="formData.phone" required></CellField>
			<CellItem label="接收科室" ref="depId" v-model="formData.depId" required itemClickType="select-department"> </CellItem>
			<CellItem label="接收人" ref="receiverUser" v-model="formData.receiverUser" itemClickType="select-user"></CellItem>
			<CellField label="接收人电话" placeholder="接收人电话" v-model="formData.receiverUserPhone" :active="false" :arrow="false"></CellField>
		</template>
	</Card>
</template>

<script>
	import Card from '@/components/card/components/cardBaseWrapper.vue'
	export default {
		components: {
			Card,
		},

		data() {
			return {

				formData: {
					sendUser: '',
					phone: '',
					depId: '',
					receiverUser: '',
					receiverUserPhone: ''
				},

			}
		},
		mounted() {
			this.init()
		},
		methods: {
			init() {
				let { deptId, deptName } = wx.getStorageSync('dept')
				let { userName, phone, id } = wx.getStorageSync('pc_userInfo')
				this.formData.receiverUser = id
				this.formData.receiverUserPhone = phone
				this.$refs.depId.resetInit(deptName)
				this.$refs.receiverUser.resetInit(userName)

				this.formData.depId = deptId

			},
			validate() {
				let msg = ''
				let {
					phone,
					depId,
					sendUser
				} = this.formData
				if (sendUser == '') {
					msg = '请输入送修人'
				} else if (depId === '') {
					msg = '请选择接收科室'
				} else if (phone == '') {
					msg = '送修人电话不能为空'
				} else {
					msg = ''
				}
				if (!msg) {
					return true
				}
				this.$msg(msg)
				return false


			}
		}
	}
</script>

<style lang="scss" scoped>


</style>
